const path = require("path");
const fs = require("fs");
var xtpl = require('xtpl');

var MongoClient = require('mongodb').MongoClient;


module.exports.getStudentList = (req,res)=>{

      var url = 'mongodb://localhost:27017/hmqd05';
    // Use connect method to connect to the Server 
    MongoClient.connect(url, function(err, db) {
      var collection = db.collection('studenttInfo');
  // Find some documents 
      collection.find({}).toArray(function(err, docs) {
            console.log(docs);
            xtpl.renderFile(path.join(__dirname,"../view/list.html"),{studentlist:docs},function(error,content){
                res.end(content);
            });
        });
    });
}
